import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { PositionService } from './position.service';
import {
  CreatePositionDto,
  FindPositionDto,
  SearchPositionDto,
  UpdatePositionDto,
} from './position.dto';
// import { Authorize } from 'src/core/decorators/index.decorator';

@ApiTags('职位管理')
@ApiBearerAuth()
@Controller('position')
export class PositionController {
  constructor(private positionService: PositionService) {}

  @Get('list')
  @ApiOperation({ summary: '获取职位列表' })
  async getPositionList(@Query() query: FindPositionDto) {
    return await this.positionService.find(query);
  }

  @Get('search')
  // @Authorize()
  @ApiOperation({ summary: '搜索职位' })
  async searchPosition(@Query() query: SearchPositionDto) {
    return await this.positionService.search(query);
  }

  @Post('create')
  @ApiOperation({ summary: '新增职位' })
  async createPosition(@Body() data: CreatePositionDto) {
    return await this.positionService.create(data);
  }

  @Put('update')
  @ApiOperation({ summary: '更新职位' })
  async updatePosition(@Body() data: UpdatePositionDto) {
    return await this.positionService.update(data);
  }
}
